/**  
 * @Title: BaseEntity.java
 * @Package com.core.entity
 * @date 2015年10月10日 下午2:14:46
 * @version V1.0  
 */
package com.shop.cloud.common.mybatis;

import java.io.Serializable;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.shop.cloud.common.mapper.OffsetDateTimeToIso8601Serializer;

import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 * 该类的功能用途 项目名称: [yfx]<br/>
 * 类名称: [BaseEntity]<br/>
 * 创建人: [GaoNan]<br/>
 * 创建时间: [2015年10月10日 下午2:14:46]<br/>
 * 修改人: [GaoNan]<br/>
 * 修改时间: [2015年10月10日 下午2:14:46]<br/>
 * 修改备注: [说明本次修改内容]<br/>
 * 版本: [v1.0]<br/>
 */
@ToString(callSuper = true)
@EqualsAndHashCode
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler", "fieldHandler" }, ignoreUnknown = true)
public class BaseEntity implements Serializable {

	public static final OffsetDateTime DEFAULT_DATE_TIME = OffsetDateTime.of(1970, 1, 1, 0, 0, 0, 0, ZoneOffset.ofHours(8));

	private static final long serialVersionUID = 1L;

	private Long id;
	
	protected Integer pageIndex = 1;
	protected Integer pageSize;
	@JsonIgnore
	protected Integer limitStart;
	@JsonIgnore
	protected Integer limitEnd;
	protected String orderBy;
	@JsonIgnore
	protected String keyword;
	@JsonSerialize(using = OffsetDateTimeToIso8601Serializer.class)
	protected OffsetDateTime startTime;
	@JsonSerialize(using = OffsetDateTimeToIso8601Serializer.class)
	protected OffsetDateTime endTime;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
	public OffsetDateTime getStartTime() {
		return startTime;
	}

	public void setStartTime(OffsetDateTime startTime) {
		this.startTime = startTime;
	}

	public OffsetDateTime getEndTime() {
		return endTime;
	}

	public void setEndTime(OffsetDateTime endTime) {
		this.endTime = endTime;
	}

	public String getKeyword() {
		return keyword;
	}

	public void setKeyword(String keyword) {
		this.keyword = keyword;
	}

	@JsonIgnore
	public Integer getPageIndex_() {
		return pageIndex;
	}

	@JsonIgnore
	public Integer getPageSize_() {
		return pageSize;
	}

	public Integer getLimitStart() {
		if (pageIndex != null && pageIndex >= 1 && pageSize != null && pageSize > 0) {
			limitStart = (pageIndex - 1) * pageSize;
		}
		return limitStart;
	}

	public void setLimitStart(Integer limitStart) {
		this.limitStart = limitStart;
	}

	public Integer getLimitEnd() {
		if (pageIndex != null && pageIndex >= 0 && pageSize != null && pageSize > 0) {
			limitEnd = pageSize;
		}
		return limitEnd;
	}

	public void setPageIndex(Integer pageIndex) {
		this.pageIndex = pageIndex;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public void setLimitEnd(Integer limitEnd) {
		this.limitEnd = limitEnd;
	}

	public String getOrderBy() {
		return orderBy;
	}

	public void setOrderBy(String orderBy) {
		this.orderBy = orderBy;
	}
}
